Skip to content

Fix #668 STJ JsonElement unwrap, #676 docs cleanup, regression guard for #692#737

Merged
YogeshPraj merged 1 commit into
microsoft:mainfrom
YogeshPraj:fix/issues-batch-5
May 30, 2026
Merged

Fix #668 STJ JsonElement unwrap, #676 docs cleanup, regression guard for #692#737
YogeshPraj merged 1 commit into
microsoft:mainfrom
YogeshPraj:fix/issues-batch-5

Conversation

@YogeshPraj
Copy link
Copy Markdown
Contributor

Summary

Batch-5 covers four of the six remaining issues. The other two (#679 rule-chaining via @RuleName, #710/#709 AGV spam) are not addressed in this PR — see "Not in this PR" below.

Fixes #668 — System.Text.Json migration: ExpandoObject + JsonElement comparisons broken

After #599 swapped Newtonsoft for STJ, properties on an ExpandoObject built from JSON came through as JsonElement values. Rule expressions like input1.country == "india" then failed with:

The binary operator Equal is not defined for the types 'System.Text.Json.JsonElement' and 'System.String'.

Utils.CreateAbstractClassType now infers the native CLR type from a JsonElement.ValueKind (string / int / long / double / bool / null), and Utils.CreateObject unwraps JsonElement scalars to their native values before assigning them. Nested objects and arrays inside the JsonElement keep their JsonElement shape — that path is for typed Newtonsoft-style models that weren't using ExpandoObject anyway.

Fixes #676ErrorType removed from docs examples

ErrorType was removed from the Rule model in 4.0.0 but still appeared in JSON examples across README.md, docs/Getting-Started.md, and docs/index.md. Removed.

Regression guard for #692 — nullable DateTime comparisons against null

User reported "null < DateTime returns false in both directions after 5.0.4." That's actually standard C# Nullable<T> semantics — both null < x and null > x are false. The pre-5.0.4 behavior was a Newtonsoft / Dynamic.Core quirk, not the documented contract.

Added an explicit test documenting both the current behavior and the canonical workaround:

"!input1.Dt.HasValue || input1.Dt < someDate"

… cleanup, document microsoft#692

for STJ, properties on an ExpandoObject built from JSON came through as
JsonElement values. Rule expressions like `input1.country == "india"` then
failed with "binary operator Equal is not defined for the types 'JsonElement'
and 'System.String'." Utils.CreateAbstractClassType now infers the native CLR
type from a JsonElement's ValueKind (string / int / long / double / bool /
null), and Utils.CreateObject unwraps JsonElement scalars to their native
values before assigning them. Objects and arrays inside the JsonElement keep
JsonElement shape — that path is for typed Newtonsoft-style models that
weren't using ExpandoObject anyway.

in JSON examples across README.md, docs/Getting-Started.md, and docs/index.md.
Removed.

after 5.0.4." That's actually standard C# Nullable<T> semantics — both
`null < x` and `null > x` are false. The pre-5.0.4 behavior was a
Newtonsoft / Dynamic.Core quirk, not the documented contract. Added an
explicit test documenting the current behavior plus the canonical
`!Dt.HasValue || Dt < someDate` workaround for users who want null-aware
ordering.

Not changed here: microsoft#679 (rule-chaining via @RuleName) is already covered
by in-flight PR microsoft#680 — no point duplicating that work. microsoft#710 and microsoft#709 are
unrelated AGV-themed spam; closing comments are in
issue-close-comments-batch-5.md.

All 164 unit tests pass on net6 / net8 / net9 / net10.
@YogeshPraj YogeshPraj force-pushed the fix/issues-batch-5 branch from 3a97d38 to ff1b585 Compare May 30, 2026 20:29
@YogeshPraj YogeshPraj merged commit 6eff220 into microsoft:main May 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants